package com.stellar.circle.domain.sCommentSensitiveLog.impl;

import com.stellar.circle.basic.entity.SCommentSensitiveLog;
import com.stellar.circle.basic.service.SCommentSensitiveLogService;
import com.stellar.circle.controller.admin.sCommentSensitiveLog.vo.SCommentSensitiveLogRequestPageVO;
import com.stellar.circle.controller.admin.sCommentSensitiveLog.vo.SCommentSensitiveLogRequestVO;
import com.stellar.circle.controller.admin.sCommentSensitiveLog.vo.SCommentSensitiveLogResponseVO;
import com.stellar.circle.convert.SCommentSensitiveLogConvert;
import com.stellar.circle.domain.sCommentSensitiveLog.SCommentSensitiveLogDomainService;
import com.stellar.web.core.bean.PageResult;
import com.stellar.web.core.enums.IsDeletedFlagEnum;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * 评论敏感词记录表领域服务实现
 * @author Jqchan
 * @version 1.0
 * @date 2025-05-19 14:52:53
 */
@Service
public class SCommentSensitiveLogDomainServiceImpl implements SCommentSensitiveLogDomainService {

    @Resource
    private SCommentSensitiveLogService sCommentSensitiveLogService;

    @Override
    public PageResult<SCommentSensitiveLogResponseVO> page(SCommentSensitiveLogRequestPageVO requestPageVO) {
        PageResult<SCommentSensitiveLogResponseVO> pageResult = new PageResult<>();
        SCommentSensitiveLog queryEntity = SCommentSensitiveLogConvert.INSTANCE.convert(requestPageVO);
        queryEntity.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getVal());
        
        List<SCommentSensitiveLog> entities = sCommentSensitiveLogService.page(queryEntity, 
            requestPageVO.getStart(), requestPageVO.getPageSize());
        
        if (entities.isEmpty()) {
            return pageResult;
        }
        
        Long count = sCommentSensitiveLogService.count(queryEntity);
        List<SCommentSensitiveLogResponseVO> vos = SCommentSensitiveLogConvert.INSTANCE.convertEntityToRespList(entities);
        
        pageResult.setResult(vos);
        pageResult.setTotal(count.intValue());
        return pageResult;
    }

    @Override
    public Boolean update(SCommentSensitiveLogRequestVO requestVO) {
        SCommentSensitiveLog entity = SCommentSensitiveLogConvert.INSTANCE.convert(requestVO);
        return sCommentSensitiveLogService.update(entity) != 0;
    }

    @Override
    public Boolean delete(Long id) {
        SCommentSensitiveLog entity = new SCommentSensitiveLog();
        entity.setId(id);
        entity.setIsDeleted(IsDeletedFlagEnum.DELETED.getVal());
        return sCommentSensitiveLogService.update(entity) != 0;
    }

    @Override
    public Boolean insert(SCommentSensitiveLogRequestVO requestVO) {
        SCommentSensitiveLog entity = SCommentSensitiveLogConvert.INSTANCE.convert(requestVO);
        return sCommentSensitiveLogService.insert(entity) != 0;
    }

    @Override
    public SCommentSensitiveLogResponseVO get(Long id) {
        SCommentSensitiveLog entity = sCommentSensitiveLogService.queryById(id);
        return SCommentSensitiveLogConvert.INSTANCE.convert(entity);
    }
}
